//
// * Copyright (c) 2002-2009 "Neo Technology,"
// *     Network Engine for Objects in Lund AB [http://neotechnology.com]
// *
// * This file is part of Neo4j.
// * 
// * Neo4j is free software: you can redistribute it and/or modify
// * it under the terms of the GNU Affero General Public License as
// * published by the Free Software Foundation, either version 3 of the
// * License, or (at your option) any later version.
// * 
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// * GNU Affero General Public License for more details.
// * 
// * You should have received a copy of the GNU Affero General Public License
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
// 
using System.IO;

namespace org.neo4j.kernel.impl.transaction.xaframework
{


///
/// <summary> * <CODE>XaDataSource</CODE> is as a factory for creating
/// * <seealso cref="XaConnection XaConnections"/>.
/// * <p>
/// * If you're writing a data source towards a XA compatible resource the
/// * implementation should be fairly straight forward. This will basically be a
/// * factory for your <seealso cref="XaConnection XaConnections"/> that in turn will wrap
/// * the XA compatible <CODE>XAResource</CODE>.
/// * <p>
/// * If you're writing a data source towards a non XA compatible resource use the
/// * <seealso cref="XaContainer"/> and extend the <seealso cref="XaConnectionHelpImpl"/> as your
/// * <seealso cref="XaConnection"/> implementation. Here is an example:
/// * <p>
/// * 
/// * <pre>
/// * <CODE>
/// * public class MyDataSource implements XaDataSource {
/// *     MyDataSource( params ) {
/// *         // ... initalization stuff
/// *         container = XaContainer.create( myLogicalLogFile, myCommandFactory, 
/// *             myTransactionFactory );
/// *         // ... more initialization stuff
/// *         container.openLogicalLog();
/// *     }
/// *     public XaConnection getXaCo nnection() {
/// *         return new MyXaConnection( params );
/// *     }
/// *     public void close() {
/// *         // ... cleanup
/// *         container.close();
/// *     }
/// * }
/// * </CODE>
/// * </pre> </summary>
/// 
	public abstract class XaDataSource
	{
		private sbyte[] branchId = null;
		private string name = null;

///    
///     <summary> * Constructor used by the Neo4j kernel to create datasources.
///     *  </summary>
///     * <param name="params">
///     *            A map containing configuration parameters </param>
///     
//JAVA TO VB & C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public XaDataSource(Map<?,?> params) throws InstantiationException
		public XaDataSource<T1>(Map<T1> @params)
		{
		}

///    
///     <summary> * Creates a XA connection to the resource this data source represents.
///     *  </summary>
///     * <returns> A connection to an XA resource </returns>
///     
		public abstract XaConnection getXaConnection();

///    
///     <summary> * Closes this data source. Calling <CODE>getXaConnection</CODE> after
///     * this method has been invoked is illegal. </summary>
///     
		public abstract void close();

///    
///     <summary> * Used by the container/transaction manager in place to assign a branch 
///     * id for this data source.
///     *  </summary>
///     * <param name="branchId"> the branch id </param>
///     
		public virtual void setBranchId(sbyte[] branchId)
		{
			this.branchId = branchId;
		}

///    
///     <summary> * Returns any assigned or default branch id for this data source.
///     *  </summary>
///     * <returns> the branch id </returns>
///     
		public virtual sbyte[] getBranchId()
		{
			return this.branchId;
		}


///    
///     <summary> * Returns a timestamp when this data source was created. Note this is not 
///     * the timestamp for the creation of the data source object instance, if  
///     * the data source is for example a database timestamp is meant to be when 
///     * the database was created.
///     * <p>
///     * Creation time together with random identifier can be used to uniqley 
///     * identify a data source (since it is possible to have multiple sources 
///     * of same type).
///     *  </summary>
///     * <returns> timestamp when this datasource was created </returns>
///     
		public virtual long getCreationTime()
		{
			throw new UnsupportedOperationException();
		}

///    
///     <summary> * Returns a random identifier that gets generated when the data source is 
///     * created. Note with "created" we mean first time data source is created 
///     * and not object creatoin.
///     * <p>
///     * Creation time together with random identifier can be used to uniqley 
///     * identify a data source (since it is possible to have multiple sources 
///     * of same type).
///     *   </summary>
///     * <returns> random identifier for this data source </returns>
///     
		public virtual long getRandomIdentifier()
		{
			throw new UnsupportedOperationException();
		}

///    
///     <summary> * Returns the current version of this data source. A invoke to the 
///     * <seealso cref="#rotateLogicalLog()"/> when <seealso cref="#keepLogicalLogs(boolean)"/> is 
///     * set to <code>true</code> will result in a log with that version created.
///     *  </summary>
///     * <returns> the current version of the logical log </returns>
///     
		public virtual long getCurrentLogVersion()
		{
			throw new UnsupportedOperationException();
		}

///    
///     <summary> * Attempts to apply a logical log to this data source.
///     *  </summary>
///     * <param name="byteChannel"> readable channel containing the logical log data
///     *  </param>
///     * <exception cref="IOException"> if a problem with reading the log occurs </exception>
///     * <exception cref="IllegalStateException"> if log being applied is not of right 
///     * version, if not in backup slave mode or there are active transactions </exception>
///     
//JAVA TO VB & C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void applyLog(ReadableByteChannel byteChannel) throws IOException
		public virtual void applyLog(ReadableByteChannel byteChannel)
		{
			throw new UnsupportedOperationException();
		}

///    
///     <summary> * Rotates this logical log. If <seealso cref="#keepLogicalLogs(boolean)"/> is 
///     * configured to true the log will be saved and can be retrieved with the 
///     * <seealso cref="#getLogicalLog(long)"/> method. If not it will be deleted. Active 
///     * transactions get copied to a new logical log.
///     *  </summary>
///     * <exception cref="IOException"> if unable to read old log or write to new one </exception>
///     
//JAVA TO VB & C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void rotateLogicalLog() throws IOException
		public virtual void rotateLogicalLog()
		{
			throw new UnsupportedOperationException();
		}

///    
///     <summary> * Returns a readable byte channel of the specified logical log.
///     *  </summary>
///     * <param name="version"> version of the logical log </param>
///     * <returns> readable byte channel of the logical log </returns>
///     * <exception cref="IOException"> if no such log exist </exception>
///     
//JAVA TO VB & C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public ReadableByteChannel getLogicalLog(long version) throws IOException
		public virtual ReadableByteChannel getLogicalLog(long version)
		{
			throw new UnsupportedOperationException();
		}

///    
///     <summary> * Tests if a specific logical log exists.
///     *  </summary>
///     * <param name="version"> the version of the logical log </param>
///     * <returns> <CODE>true</CODE> if the log exists </returns>
///     
		public virtual bool hasLogicalLog(long version)
		{
			throw new UnsupportedOperationException();
		}


///    
///     <summary> * Deletes a log specific logical log.
///     *  </summary>
///     * <param name="version"> version of log to delete
///     *  </param>
///     * <returns> true if the log existed and was deleted </returns>
///     
		public virtual bool deleteLogicalLog(long version)
		{
			throw new UnsupportedOperationException();
		}

///    
///     <summary> * Sets wether logical logs should be saved upon rotation or not. Default 
///     * is <CODE>false</CODE>.
///     *  </summary>
///     * <param name="keepLogs"> <CODE>true</CODE> means save, <CODE>false</CODE> means 
///     * delete </param>
///     
		public virtual void keepLogicalLogs(bool keepLogs)
		{
			throw new UnsupportedOperationException();
		}

///    
///     <summary> * Used by the container to assign a name to this resource. 
///     *  </summary>
///     * <param name="name"> name of this resource </param>
///     
		public virtual string Name
		{
			set
			{
				this.name = value;
			}
			get
			{
				return name;
			}
		}

///    
///     <summary> * Returns the assigned name of this resource.
///     *  </summary>
///     * <returns> the assigned name of this resource </returns>
///     

///    
///     <summary> * Makes this data source a backup slave. This method can not be called 
///     * while there are active transactions. Once set in "backup slave" mode 
///     * no new transactions can start, the resource has to be closed and 
///     * reopened for that.
///     * </summary>
///     * <exception cref="IllegalStateException"> if this resource has active transactions </exception>
///     
		public virtual void makeBackupSlave()
		{
			throw new UnsupportedOperationException();
		}

///    
///     <summary> * Turns off/on auto rotate of logical logs. Default is <CODE>true</CODE>.
///     *  </summary>
///     * <param name="rotate"> <CODE>true</CODE> to turn on </param>
///     
		public virtual void setAutoRotate(bool rotate)
		{
			throw new UnsupportedOperationException();
		}

///    
///     <summary> * Sets the target size of the logical log that will cause a rotation of 
///     * the log if <seealso cref="#setAutoRotate(boolean)"/> is set to <CODE>true</CODE>.
///     *  </summary>
///     * <param name="size"> target size in bytes </param>
///     
		public virtual void setLogicalLogTargetSize(long size)
		{
			throw new UnsupportedOperationException();
		}
	}
}